#include <stdio.h>
#include <string.h>

struct sfs
{
	char shu[105];
	char tot[105];
}tt[10000];

char in1[105],in2[105],out[105];

void change(char *s)
{
	int len,i;
	memset(in1,0,sizeof(in1));
	len=strlen(s);
	in1[0]=len;
	for (i=1;i<=len;i++)
		in1[i]=s[len-i]-'0';
}
void change2(char *s)
{
	int len,i;
	memset(in2,0,sizeof(in1));
	len=strlen(s);
	in2[0]=len;
	for (i=1;i<=len;i++)
		in2[i]=s[len-i]-'0';
}


void add(char *s1, char *s2, char *an)
{
	int i,j,site,len;
	char to[105];

	memset(to,0,sizeof(to));	
	len=s1[0]>s2[0] ? s1[0]:s2[0];
	for (i=1;i<=len;i++)	
	{		
		to[i]+=s1[i]+s2[i];
		if (to[i]>=10)
		{
			to[i+1]+=to[i]/10;
			to[i]%=10;
		}
	}	
	while (to[len+1]!=0) len++;
	to[0]=len;
	for (i=0;i<=len;i++)
		an[i]=to[i];
}

void sub(char *s1, char *s2, char *an)
{
	int i,j,len;
	char to[105];
	memset(to,0,sizeof(to));
	len=s1[0];
	for (i=1;i<=s1[0];i++)
		to[i]=s1[i];
	for (i=1;i<=len;i++)
	{
		to[i]-=s2[i];
		if (to[i]<0)
		{
			to[i+1]--;
			to[i]+=10;
		}
	}
	while (to[len]==0) len--;
	to[0]=len;
	for (i=0;i<=len;i++)
		an[i]=to[i];
}

int da(char *s1,char *s2)
{
	int i;
	if (s1[0]>s2[0]) return 1;
	if (s1[0]<s2[0]) return 0;
	for (i=s1[0];i>=1;i--)
	{
		if (s1[i]>s2[i]) return 1;
		if (s1[i]<s2[i]) return 0;
	}
	return 2;
}

main()
{
	int i,j,num;
	char yi[100];
	memset(tt,0,sizeof(tt));
	memset(yi,0,sizeof(yi));
	tt[1].shu[0]=1; 	tt[1].shu[1]=1;
	tt[1].tot[0]=1;  	tt[1].tot[1]=1;
	tt[2].shu[0]=1;		tt[2].shu[1]=2;
	tt[2].tot[0]=1;		tt[2].tot[1]=2;
	
	
	i=num=2;
	yi[0]=1;
	yi[1]=1;
	while (tt[i].shu[0]<=100)
	{
		i++;
		num++;
		add(tt[i-2].shu,tt[i-1].shu,tt[i].shu);
		add(tt[i-1].tot,yi,tt[i].tot);
	}	
	
	char a[105],b[105];
	
	while (1)
	{
		scanf("%s%s", a, b);
		if (a[0]=='0' && b[0]=='0') break;
		change(a);
		change2(b);
		i=1;
		
		while (da(in1,tt[i].shu)==1) 
			i++;
		if (da(in1,tt[i].shu)==2) 
		{
			j=1;
			i++;
		}
		else 
		{
			j=0;		
		}
		
		while (da(in2,tt[i].shu)==1)
		{	
			j++;
			i++;
		}
		if (da(in2,tt[i].shu)==2) j++;
		

		
	//	sub(tt[j].tot,tt[i+1].tot,out);
//		for (i=out[0];i>=1;i--)
//			printf("%d",out[i]);
		printf("%d\n",j);


		
	}
	
	
	

	return 0;
}